local ServerOHOH = _G.ServerOHOH;
local M = ServerOHOH.class.new(script, ServerOHOH.files.Server_PlayerComponent(),script.Parent.Name);
local EventList = ServerOHOH.load.EventList();

local Tool=require(script.Parent.tool)
local gCfg=Tool.GetConfg()

local ItemTool=_G.CommonOHOH.load.ItemTool();
local function_list = ServerOHOH.function_list;
function M.new(self)
	return M(self);
end;
function M.ctor(self, parent)
	M.super.ctor(self, parent);
	self.player=self.parent
	self.ItemCtrl=self.parent:GetComponent(ServerOHOH.load.Server_ItemCtrl());

	self.dataBase=self.parent:GetComponent(ServerOHOH.load.Server_PlayerDataComponent());
    self.data = self.dataBase:GetData("activity_2");
	self.needTime=gCfg.OnlineTime;
	self.list = gCfg.list
  self.player.RobuxBuyDoneEvent:Connect(function(gid,gtype)
		if gtype=="skip_active_2" then
			self:Fire(EventList.quest_buydone);
            self:DistributeRewards()
		end
	end)
	

end;
function  M.DistributeRewards(self)
	for k,v in self.list do
	self.ItemCtrl:AddAnyThing(k,v);	
	end
end

function M.dtor(self)
	if self.taskConnect  then
		self.taskConnect:Disconnect();
		self.taskConnect=nil;
	end
	if self.task then
		self.task:dtor();
    end
	M.super.dtor(self)
end;

M:RegistFunction(function_list.distribute_rewards,M.DistributeRewards)
return M;